/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * <p>Project: app2022 - Set1
 * <p>Powered by webrx On 2022-01-14 17:19:37
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Set1 {
    public static void main(String[] args) {
        //Collection->List ArrayList
        var list = new ArrayList<Integer>(List.of(11, 22, 33, 11, 44, 55, 11, 66));
        System.out.println(list.size());
        System.out.println(list);

        //Collection->Set HashSet(集合对象不能重复，重复保留一个，元素没有顺序，不参随机访问
        var set = new HashSet<Integer>(List.of(11, 22, 33, 11, 44, 55, 11, 66));
        System.out.println(set.size());
        System.out.println(set);
        System.out.println(set.contains(11)); //true
        set.remove(66);
        set.removeAll(List.of(55, 44, 11));
        System.out.println(set);

        //遍历
        for(Integer i : set){
            System.out.println(i);
        }

        //lambda forEach表达 遍历输出
        set.forEach(System.out::println);
    }
}
